package disk

import (
	"bytes"
	"context"
	"github.com/sirupsen/logrus"
	"os/exec"
)

func MakeExt4(ctx context.Context, partition string) (err error) {
	cmd := exec.CommandContext(ctx, "mkfs.ext4", "-F", partition)
	var stdout, stderr bytes.Buffer
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	logrus.Debugf("%+v", cmd.Args)
	err = cmd.Run()
	if err != nil {
		logrus.Warnf("mkfs.ext4 failed with %s", err)
	}
	logrus.Debugf("result %v, error %v", stdout.String(), stderr.String())
	return
}
